Class Objects.Moveable

Represents any object inside the game world.

Examples include traps, enemies, doors, pickups, and Lara herself (see also Objects.LaraObject for Lara-specific features).

Functions

Moveable(object, name, position[, rotation][, room][, animNumber=0][, frameNumber=0][, hp=10][, OCB=0][, AIBits]) For more information on each parameter, see the associated getters and setters.
Moveable:Enable() Enable the item, as if a trigger for it had been stepped on.
Moveable:Disable() Disable the item
Moveable:MakeInvisible() Make the item invisible.
Moveable:Explode() Explode item.
Moveable:Shatter() Shatter item.
Moveable:SetEffect(effect, timeout) Set effect to moveable
Moveable:SetCustomEffect(Color1, Color2, timeout) Set custom colored burn effect to moveable
Moveable:GetEffect() Get current moveable effect
Moveable:GetStatus() Get the status of object.
Moveable:SetOnHit(callback) Set the name of the function to be called when the moveable is shot by Lara Note that this will be triggered twice when shot with both pistols at once.
Moveable:SetOnCollidedWithObject(func) Set the function to be called called when this moveable collides with another moveable
Moveable:SetOnCollidedWithRoom(func) Set the function called when this moveable collides with room geometry (e.g.
Moveable:SetOnKilled(callback) Set the name of the function to be called when the moveable is destroyed/killed Note that enemy death often occurs at the end of an animation, and not at the exact moment the enemy's HP becomes zero.
Moveable:GetObjectID() Retrieve the object ID
Moveable:SetObjectID(ID) Change the object's ID.
Moveable:GetState() Retrieve the index of the current state.
Moveable:SetState(index) Set the object's state to the one specified by the given index.
Moveable:GetAnim() Retrieve the index of the current animation.
Moveable:SetAnim(index) Set the object's animation to the one specified by the given index.
Moveable:GetFrame() Retrieve frame number.
Moveable:SetVelocity(velocity) Set the object's velocity to specified value.
Moveable:GetVelocity() Get the object's velocity.
Moveable:SetFrame(frame) Set frame number.
Moveable:GetSlotHP(ID) Get HP definded for that object type (hit points/health points) (Read Only).
Moveable:GetOCB() Get OCB (object code bit) of the moveable
Moveable:SetOCB(OCB) Set OCB (object code bit) of the moveable
Moveable:GetItemFlags() Get the value stored in ItemFlags[x] (x is the value of the parameter)
Moveable:SetItemFlags(value) Stores the value of the first parameter in the ItemFlags[x] (x is the value of the second parameter)
Moveable:GetColor() Get the moveable's color
Moveable:SetColor(color) Set the moveable's color
Moveable:GetAIBits() Get AIBits of object This will return a table with six values, each corresponding to an active behaviour.
Moveable:SetAIBits(bits) Set AIBits of object Use this to force a moveable into a certain AI mode or modes, as if a certain nullmesh (or more than one) had suddenly spawned beneath their feet.
Moveable:MeshIsVisible(index) Get state of specified mesh visibility of object Returns true if specified mesh is visible on an object, and false if it is not visible.
Moveable:ShowMesh(index) Makes specified mesh visible Use this to show specified mesh of an object.
Moveable:HideMesh(index) Makes specified mesh invisible Use this to hide specified mesh of an object.
Moveable:ShatterMesh(index) Shatters specified mesh and makes it invisible Note that you can re-enable mesh later by using ShowMesh().
Moveable:MeshIsSwapped(index) Get state of specified mesh swap of object Returns true if specified mesh is swapped on an object, and false if it is not swapped.
Moveable:SwapMesh(index, index, optional) Set state of specified mesh swap of object Use this to swap specified mesh of an object.
Moveable:UnswapMesh(index) Set state of specified mesh swap of object Use this to bring back original unswapped mesh
Moveable:GetHitStatus() Get the hit status of the object
Moveable:GetActive() Determine whether the moveable is active or not
Moveable:GetJointPosition(index) Get the object's joint position
Moveable:GetRotation() Get the moveable's rotation
Moveable:SetRotation(rotation) Set the moveable's rotation
Moveable:GetName() Get the moveable's name (its unique string identifier) e.g.
Moveable:SetName(string) Set the moveable's name (its unique string identifier) e.g.
Moveable:GetValid() Test if the object is in a valid state (i.e.
Moveable:Destroy() Destroy the moveable.
Moveable:AttachObjCamera(mesh) Attach camera to an object.
Moveable:AnimFromObject(ObjectID, animNumber, stateID) Borrow animation from an object
Moveable:GetPosition() Get the object's position
Moveable:SetPosition(position[, updateRoom]) Set the moveable's position If you are moving a moveable whose behaviour involves knowledge of room geometry, (e.g.
Moveable:GetHP() Get current HP (hit points/health points)
Moveable:SetHP(HP) Set current HP (hit points/health points) Clamped to [0, 32767] for "intelligent" entities (i.e.
Moveable:GetRoom() Get the current room of the object
Moveable:SetRoom(ID) Set room of object Use this if you are not using SetPosition's automatic room update - for example, when dealing with overlapping rooms.


Functions

Moveable(object, name, position[, rotation][, room][, animNumber=0][, frameNumber=0][, hp=10][, OCB=0][, AIBits])
For more information on each parameter, see the associated getters and setters. If you do not know what to set for these, most can just be ignored (see usage).

Parameters:

  • object ObjID ID
  • name string Lua name of the item
  • position Vec3 position in level
  • rotation Rotation rotation about x, y, and z axes (default Rotation(0, 0, 0)) (optional)
  • room int room ID item is in (default: calculated automatically) (optional)
  • animNumber int anim number (default 0)
  • frameNumber int frame number (default 0)
  • hp int HP of item (default 10)
  • OCB int ocb of item (default 0) (default 0)
  • AIBits table table with AI bits (default {0,0,0,0,0,0}) (optional)

Returns:

    Moveable A new Moveable object (a wrapper around the new object)

Usage:

    local item = Moveable(
    	TEN.Objects.ObjID.PISTOLS_ITEM, -- object id
    	"test", -- name
    	Vec3(18907, 0, 21201)
    	)
Moveable:Enable()
Enable the item, as if a trigger for it had been stepped on.
Moveable:Disable()
Disable the item
Moveable:MakeInvisible()
Make the item invisible. Use EnableItem to make it visible again.
Moveable:Explode()
Explode item. This also kills and disables item.
Moveable:Shatter()
Shatter item. This also kills and disables item.
Moveable:SetEffect(effect, timeout)
Set effect to moveable

Parameters:

  • effect EffectID Type of effect to assign.
  • timeout float time (in seconds) after which effect turns off (optional).
Moveable:SetCustomEffect(Color1, Color2, timeout)
Set custom colored burn effect to moveable

Parameters:

  • Color1 Color color the primary color of the effect (also used for lighting).
  • Color2 Color color the secondary color of the effect.
  • timeout float time (in seconds) after which effect turns off (optional).
Moveable:GetEffect()
Get current moveable effect

Returns:

    EffectID effect type currently assigned to moveable.
Moveable:GetStatus()
Get the status of object. possible values:
0 - not active
1 - active
2 - deactivated
3 - invisible

Returns:

    int a number representing the status of the object
Moveable:SetOnHit(callback)
Set the name of the function to be called when the moveable is shot by Lara Note that this will be triggered twice when shot with both pistols at once.

Parameters:

  • callback function function in LevelFuncs hierarchy to call when moveable is shot
Moveable:SetOnCollidedWithObject(func)
Set the function to be called called when this moveable collides with another moveable

Parameters:

  • func function callback function to be called (must be in LevelFuncs hierarchy)
Moveable:SetOnCollidedWithRoom(func)
Set the function called when this moveable collides with room geometry (e.g. a wall or floor)

Parameters:

  • func function callback function to be called (must be in LevelFuncs hierarchy)
Moveable:SetOnKilled(callback)
Set the name of the function to be called when the moveable is destroyed/killed Note that enemy death often occurs at the end of an animation, and not at the exact moment the enemy's HP becomes zero.

Parameters:

  • callback function function in LevelFuncs hierarchy to call when enemy is killed

Usage:

    LevelFuncs.baddyKilled = function(theBaddy) print("You killed a baddy!") end
    baddy:SetOnKilled(LevelFuncs.baddyKilled)
Moveable:GetObjectID()
Retrieve the object ID

Returns:

    int a number representing the ID of the object
Moveable:SetObjectID(ID)
Change the object's ID. This will literally change the object.

Parameters:

  • ID ObjectID the new ID

Usage:

    shiva = TEN.Objects.GetMoveableByName("shiva_60")
    shiva:SetObjectID(TEN.Objects.ObjID.BIGMEDI_ITEM)
Moveable:GetState()
Retrieve the index of the current state. This corresponds to the number shown in the item's state ID field in WadTool.

Returns:

    int the index of the active state
Moveable:SetState(index)
Set the object's state to the one specified by the given index. Performs no bounds checking. Ensure the number given is correct, else object may end up in corrupted animation state.

Parameters:

  • index int the index of the desired state
Moveable:GetAnim()
Retrieve the index of the current animation. This corresponds to the number shown in the item's animation list in WadTool.

Returns:

    int the index of the active animation
Moveable:SetAnim(index)
Set the object's animation to the one specified by the given index. Performs no bounds checking. Ensure the number given is correct, else object may end up in corrupted animation state.

Parameters:

  • index int the index of the desired anim
Moveable:GetFrame()
Retrieve frame number. This is the current frame of the object's active animation.

Returns:

    int the current frame of the active animation
Moveable:SetVelocity(velocity)
Set the object's velocity to specified value. In most cases, only Z and Y components are used as forward and vertical velocity. In some cases, primarily NPCs, X component is used as side velocity.

Parameters:

  • velocity Vec3 velocity represented as vector
Moveable:GetVelocity()
Get the object's velocity. In most cases, only Z and Y components are used as forward and vertical velocity. In some cases, primarily NPCs, X component is used as side velocity.

Returns:

    Vec3 current object velocity
Moveable:SetFrame(frame)
Set frame number. This will move the animation to the given frame. The number of frames in an animation can be seen under the heading "End frame" in the WadTool animation editor. If the animation has no frames, the only valid argument is -1.

Parameters:

  • frame int the new frame number
Moveable:GetSlotHP(ID)
Get HP definded for that object type (hit points/health points) (Read Only).

Parameters:

  • ID int of the moveable slot type.
Moveable:GetOCB()
Get OCB (object code bit) of the moveable

Returns:

    int the moveable's current OCB value
Moveable:SetOCB(OCB)
Set OCB (object code bit) of the moveable

Parameters:

  • OCB int the new value for the moveable's OCB
Moveable:GetItemFlags()
Get the value stored in ItemFlags[x] (x is the value of the parameter)

Returns:

    short id of the ItemFlags array
Moveable:SetItemFlags(value)
Stores the value of the first parameter in the ItemFlags[x] (x is the value of the second parameter)

Parameters:

  • value short to store in the moveable's ItemFlags[x], short id of ItemFlags array to store the value.
Moveable:GetColor()
Get the moveable's color

Returns:

    Color a copy of the moveable's color
Moveable:SetColor(color)
Set the moveable's color

Parameters:

  • color Color the new color of the moveable
Moveable:GetAIBits()
Get AIBits of object This will return a table with six values, each corresponding to an active behaviour. If the object is in a certain AI mode, the table will have a 1 in the corresponding cell. Otherwise, the cell will hold a 0. 1 - guard 2 - ambush 3 - patrol 1 4 - modify 5 - follow 6 - patrol 2

Returns:

    table a table of AI bits
Moveable:SetAIBits(bits)
Set AIBits of object Use this to force a moveable into a certain AI mode or modes, as if a certain nullmesh (or more than one) had suddenly spawned beneath their feet.

Parameters:

  • bits table the table of AI bits

Usage:

    local sas = TEN.Objects.GetMoveableByName("sas_enemy")
    sas:SetAIBits({1, 0, 0, 0, 0, 0})
Moveable:MeshIsVisible(index)
Get state of specified mesh visibility of object Returns true if specified mesh is visible on an object, and false if it is not visible.

Parameters:

  • index int of a mesh

Returns:

    bool visibility status
Moveable:ShowMesh(index)
Makes specified mesh visible Use this to show specified mesh of an object.

Parameters:

  • index int of a mesh
Moveable:HideMesh(index)
Makes specified mesh invisible Use this to hide specified mesh of an object.

Parameters:

  • index int of a mesh
Moveable:ShatterMesh(index)
Shatters specified mesh and makes it invisible Note that you can re-enable mesh later by using ShowMesh().

Parameters:

  • index int of a mesh
Moveable:MeshIsSwapped(index)
Get state of specified mesh swap of object Returns true if specified mesh is swapped on an object, and false if it is not swapped.

Parameters:

  • index int of a mesh

Returns:

    bool mesh swap status
Moveable:SwapMesh(index, index, optional)
Set state of specified mesh swap of object Use this to swap specified mesh of an object.

Parameters:

  • index int of a slot to get meshswap from
  • index int of a slot to get meshswap from
  • optional int ) index of a mesh from meshswap slot to use
Moveable:UnswapMesh(index)
Set state of specified mesh swap of object Use this to bring back original unswapped mesh

Parameters:

  • index int of a mesh to unswap
Moveable:GetHitStatus()
Get the hit status of the object

Returns:

    bool true if the moveable was hit by something in the last gameplay frame, false otherwise
Moveable:GetActive()
Determine whether the moveable is active or not

Returns:

    bool true if the moveable is active
Moveable:GetJointPosition(index)
Get the object's joint position

Parameters:

  • index int of a joint to get position

Returns:

    Vec3 a copy of the moveable's position
Moveable:GetRotation()
Get the moveable's rotation

Returns:

    Rotation a copy of the moveable's rotation
Moveable:SetRotation(rotation)
Set the moveable's rotation

Parameters:

  • rotation Rotation The moveable's new rotation
Moveable:GetName()
Get the moveable's name (its unique string identifier) e.g. "door_back_room" or "cracked_greek_statue" This corresponds with the "Lua Name" field in an object's properties in Tomb Editor.

Returns:

    string the moveable's name
Moveable:SetName(string)
Set the moveable's name (its unique string identifier) e.g. "door_back_room" or "cracked_greek_statue" It cannot be blank and cannot share a name with any existing object.

Parameters:

  • string name the new moveable's name

Returns:

    bool true if we successfully set the name, false otherwise (e.g. if another object has the name already)
Moveable:GetValid()
Test if the object is in a valid state (i.e. has not been destroyed through Lua or killed by Lara).

Returns:

    bool valid true if the object is still not destroyed
Moveable:Destroy()
Destroy the moveable. This will mean it can no longer be used, except to re-initialise it with another object.
Moveable:AttachObjCamera(mesh)
Attach camera to an object.

Parameters:

  • mesh int 1 for camera, mesh 2 for target
Moveable:AnimFromObject(ObjectID, animNumber, stateID)
Borrow animation from an object

Parameters:

  • ObjectID ObjID to take animation and stateID from,
  • animNumber int animation from object
  • stateID int state from object
Moveable:GetPosition()
Get the object's position

Returns:

    Vec3 a copy of the moveable's position
Moveable:SetPosition(position[, updateRoom])
Set the moveable's position If you are moving a moveable whose behaviour involves knowledge of room geometry, (e.g. a BADDY1, which uses it for pathfinding), then the second argument should be true (or omitted, as true is the default). Otherwise, said moveable will not behave correctly.

Parameters:

  • position Vec3 the new position of the moveable
  • updateRoom bool Will room changes be automatically detected? Set to false if you are using overlapping rooms (default: true) (optional)
Moveable:GetHP()
Get current HP (hit points/health points)

Returns:

    int the amount of HP the moveable currently has
Moveable:SetHP(HP)
Set current HP (hit points/health points) Clamped to [0, 32767] for "intelligent" entities (i.e. anything with AI); clamped to [-32767, 32767] otherwise.

Parameters:

  • HP int the amount of HP to give the moveable
Moveable:GetRoom()
Get the current room of the object

Returns:

    int number representing the current room of the object
Moveable:SetRoom(ID)
Set room of object Use this if you are not using SetPosition's automatic room update - for example, when dealing with overlapping rooms.

Parameters:

  • ID int the ID of the new room

Usage:

    local sas = TEN.Objects.GetMoveableByName("sas_enemy")
    sas:SetRoom(destinationRoom)
    sas:SetPosition(destinationPosition, false)
generated by LDoc 1.4.6 Last updated 2022-12-16 18:35:53